home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MODULES / CSDVAR.ZIP / ReadMe < prev   
Text File  |  1997-10-25  |  9KB  |  225 lines

  1. CSDVar Module, V2.13 © Musus Umbra, 1996/7
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3.  
  4. Do you sometimes wish that Risc OS had the 'Prompt $P' functionality of
  5. DOS?  Do you find it tricky remembering where you are in a directory
  6. tree when using the command line?  Ever wanted the unix 'pwd' command?
  7.  
  8. Then CSDVar is for you!
  9.  
  10. **NEW**
  11. CSDVar now also implements a 'directory stack' with pushdir & popdir commands
  12. (amongst others).
  13.  
  14. **NEW**
  15. CSDVar provides AddToPath and PrependToPath for more sensible setting of
  16. path variables (ie. it ensures that the added directory doesn't exist in
  17. the path already, etc.)
  18.  
  19.  
  20. What is it?
  21. ~~~~~~~~~~~
  22. CSDVar is a (tiny) module that provides the following functions:
  23.     (1) A *command, 'pwd' that prints out the full pathname
  24.         of the current directory.
  25.     (2) A SWI, CSDVar_Read (&CD0C0) that reads the full
  26.         pathname of the CSD and returns a pointer to it.
  27.     (3) A system variable, CSD$Var that whenever inspected
  28.         will hold the pathname of the CSD.
  29.  
  30.     *** From here on is new to 2.01 ***
  31.  
  32.     (4) Long pathnames can be 'clipped' to a reasonable length, with
  33.         some suitable 'elipsis' string inserted in the middle.
  34.         (this only affects the CSD$Var variable, the SWI and *pwd
  35.         still give the full pathname)
  36.     (5) A SWI CSDVar_MaxLen (&CD0C1) that can be used to read/set the
  37.         'clipping' length and/or the 'elipsis' string
  38.     (6) The CSD$Var variable can now be written to (with much the
  39.         same effect as using the MaxLen SWI)
  40.     (7) The 'clipping' function is available via the SWI
  41.         CSDVar_Clip (&CD0C2), (see the source)
  42.     (8) Reasonable *Help text (compacted with the OS dictionary)
  43.     (9) Larger buffer for CSD pathname (440 bytes!)
  44.     (A) Documentation that -gasp- makes sense!
  45.  
  46.     *** From here on is new to 2.13 ***
  47.  
  48.     (B) Bug fix in invalid SWI code (damn that PRM)
  49.     (C) New code variable 'PWD$Var' (like CSD$Var but without any
  50.         clipping).
  51.     (D) Modifications to AddToPath so that when adding to an empty
  52.         path a leading ',' inserted.  The old code would omit the comma
  53.         (and so set the path rather than adding to it).  Eg. if foo$path
  54.         is empty, "AddToPath Foo$Path Frob" will now result in foo$path
  55.         becoming ",Frob." rather than "Frob."
  56.     (E) Lots more SWIs (mostly for internal use so undocumented.  Look
  57.         at the source if you're interested).
  58.     (F) Documentation that's -gasp- up to date!
  59.  
  60.  
  61. How to use it
  62. ~~~~~~~~~~~~~
  63. Probably the best and simplest use is to load the module in your boot
  64. sequence, and then issue a
  65.     *SetMacro CLI$Prompt <CSD$Var> *
  66. command.  Now, whenever you'd normally be presented with a '*' prompt on the
  67. command line, you'll instead have the full pathname of the CSD displayed, and
  68. then the *.
  69.  
  70. I find this incredibly useful, since I'm always using taskwindows, or ducking
  71. out of the desktop (F12) to do some command line stuff, and I often need to
  72. keep track of where I am in the directory tree.
  73.  
  74.  
  75. But I already have something that does that!
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. So did I, but the utility I was using had (at least) one fundamental problem:
  78. if the CSD's pathname couldn't be read (due to an error), it caused an endless
  79. string of error messages, often necessitating a reboot.  CSDVar doesn't do
  80. that. If there's an error reading the CSD pathname, then CSDVar will tell you
  81. what the error was in place of the CSD's pathname.  Try it on ADFS::0
  82. without a disc in the drive and you'll see what I mean.  The utility I was
  83. using would have spewed continuous 'Drive empty' messages at me until I'd
  84. appeased it by putting a disc in the drive.  CSDVar will just say 'Drive empty'
  85. once and be done with it.  Much better.
  86.  
  87.  
  88. What was all that about 'clipping' and 'elipsis' then?
  89. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. This is new to V2.01.
  91.  
  92. If you're like me, you like your discs to have a meticulously organised
  93. directory tree, and the thought of a directory with more than about ten
  94. files in it brings you out in the screaming heeby-geebies (can you say
  95. 'Anal Retentive', Mr. Freud?), then you'll doubtless have very deep
  96. directory trees.  In these circumstances, having the CSD in the CLI
  97. prompt is *very* useful, but it does get a bit annoying when the CSD's
  98. pathname runs to 70 characters or more...
  99.  
  100. So, 'clipping'.  Basically, you can tell CSDVar to ensure that the CSD$Var
  101. variable (NB: *not* the output of the *pwd command, or CSDVar_Read swi!)
  102. is never longer than a certain length.  Now, we don't want to chop off the
  103. start of the path - that contains useful things like the disc name, and we
  104. can't chop off the end - that contains the directory name.  So, we chop out
  105. the middle, and replace it with an 'elipsis' string (elipsis is the
  106. symbol '…', sometimes written ... that means 'something missed out here').
  107. You can even specify the elipsis string! (The default is " … ").
  108.  
  109. You control the maximum length and elipsis string by *set-ing the CSD$Var
  110. variable:
  111.  
  112.     *set CSD$Var <max length> [<elipsis string>]
  113.  
  114. Note that you *must* supply the maximum length parameter - if you don't
  115. want to alter the maximum length currently in force, give the new max length
  116. as 0.
  117.  
  118. If you want to include spaces in the elipsis string (eg. to set it to
  119. the less claustrophobic " ... "), then you should surround the string with
  120. double-quotation marks ("s).
  121.  
  122. The backslash (\) character means "use the next character 'as is', don't try
  123. anything fancy with it, schmuck!".  So, you could do that last example with
  124.     *set CSD$Var 0 \ ...\        (NB: there's a space after that last \)
  125. but you'd be daft to.  Use \" to include a ", \\ for a \.
  126.  
  127. Watch out! if you want to use the < character, you have to prefix it with
  128. a pipe (|) character - this isn't my fault! eg:
  129.     *set CSD$Var 0 <chomp>
  130. doesn't set the elipsis string to "<chomp>", it sets it to the contents of
  131. the system variable 'chomp' - this is because RISC OS GSTrans's the command
  132. line *before* CSDVar gets a look at it.
  133.     *set CSD$Var 0 |<chomp>
  134. does the trick though.
  135.  
  136. If you want to 'unset' the elipsis string (ie. set it to ""), then simply
  137. set it to "":
  138.     *set CSD$Var 0 ""
  139. (note that you have to supply the "", if you don't then CSDVar will simply
  140. think that you've omitted the elipsis string because you didn't want to
  141. alter it).
  142.  
  143.  
  144.  
  145. *Commands
  146. ~~~~~~~~~
  147. The module provides plenty of *Help text :-)
  148.  
  149.  
  150.  
  151. Technical Stuff & SWI calls
  152. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153. The CSDVar SWI chunk is &CD0C0 (unregistered)
  154.  
  155. The SWIs are (all regs not documented are preserved)
  156.  
  157. SWI CSDVar_Read (&CD0C0)
  158.     On Entry:    -
  159.     On Exit:    r0->the full pathname of the CSD (or error string)
  160.     Description:
  161.         This swi is used internally (the code variable can't
  162.         get at the module's workspace directly, so it does all
  163.         its 'dirty' work via swi calls).
  164.  
  165. SWI CSDVar_MaxLen (&CD0C1)
  166.     On Entry:    r0 = new max length of CSD$Var, or 0 to leave alone
  167.             r1 = new elipsis string, or 0 to leave alone
  168.     On exit:    r0 = max length in effect after the call
  169.             r1 -> elipsis string in effect after the call
  170.     Description:
  171.         Once again, this is a swi that's only there because the
  172.         code variable can't get at the module workspace itself.
  173.         When the code variable is written to, it parses the
  174.         'arguments' and calls this swi. Note that the elipsis
  175.         string isn't processed in any way:
  176.             *set CSD$Var 0 |<chomp>\"Hi\"
  177.         is not the same as:
  178.             SYS "CSDVar_MaxLen",0,"|<chomp>\""Hi\"""
  179.         even though the elipsis string arguments are the same!
  180.         (the *set results in <chomp>"Hi", whereas the swi results
  181.         in |<chomp>\"Hi\").
  182.         Actually, the code variable uses the elipsis pointer
  183.         returned to overwrite the current string, rather than
  184.         passing a new string in.  Yicky, I know, but it saves
  185.         a huge amount of hassle.
  186.  
  187.  
  188.  
  189. Background
  190. ~~~~~~~~~~
  191. Basically, I'd been using a similar utility to set the CLI prompt to the
  192. name of the CSD, but I'd got increasingly upset with it.  The principal
  193. problem was that if the CSD couldn't be read for some reason (eg. I'd changed
  194. to IDEFS, but my IDE drive is disconnected now that I have a bigger, faster
  195. SCSI drive) and there was an error, I'd get an endless stream of (for
  196. instance) 'Bad Drive's appearing when I hit F12, and the only option would be
  197. a re-boot.  Now, why the Hell didn't whoever wrote the utility I was using
  198. simply trap the error and use that for the name of the CSD in the system
  199. prompt?  I don't know, but that's exactly what my module does.  Also, my module
  200. will allow you to 'unset' the system variable it provides - not fantastically
  201. useful, but if for some arcane reason you want to, you can.
  202.  
  203.  
  204. Disclaimer
  205. ~~~~~~~~~~
  206. Use of this software is completely at your own risk. The author can accept no
  207. responsibility for any damage/loss arising from the use, or inability to use
  208. this software. No warranty, express or implied, applies to this software.
  209. This is not PD: the Copyright in this software belongs at all times to the
  210. author. However, permission is granted for unrestricted distribution
  211. prodividing that *no* charge is made for the distribution [a charge may be made
  212. for handling/media] and that the whole of the software is supplied intact and
  213. unaltered. Permission is also granted for unrestricted use and alteration of
  214. the software [but if you fix a bug / add anything nice, let me know so I can
  215. patch the 'master' version].
  216.  
  217.  
  218.  
  219. Bug reports / comments / etc to:
  220.  
  221. Musus Umbra c/o 23 Baronsway, Whitkirk, Leeds, LS15 7AW, England.
  222.  
  223. e-mail: musus@argonet.co.uk
  224. www:    http://www.argonet.co.uk/users/musus/
  225.